package util;

import javazoom.jl.decoder.JavaLayerException;
import javazoom.jl.player.Player;
import java.io.BufferedInputStream;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.util.logging.Level;
import java.util.logging.Logger;

public class LoopMusicPlayer extends Thread{
    private Player player;
    private String musicName;
   // BufferedInputStream buffer;
    //加载音乐
    public LoopMusicPlayer(String fileName){
        this.musicName = fileName;
    }

    @Override
    public void run() {
        while (true) {
            try {
                player = new Player(new BufferedInputStream(new FileInputStream(musicName)));
                player.play();
            } catch (JavaLayerException ex) {
                Logger.getLogger(LoopMusicPlayer.class.getName()).log(Level.SEVERE, null, ex);
            } catch (FileNotFoundException e) {
                e.printStackTrace();
            }
        }
    }
}
